var express=require('express');
var app =express();
var bodyParser = require('body-parser');
//引用bodyParser 这个不要忘了写

//设置跨域访问
app.all('*', function(req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
    res.header("X-Powered-By",' 3.2.1');
    res.header("Content-Type", "application/json;charset=utf-8");
    next();
});
var questions=
    {
        data:213,
        num:444,
        age:12
    };
//写个接口123
app.get('/',function(req,res){
	console.log(req.params)
    res.status(200),
        res.json(fx())
});
function fx(val){
	return {a:123}
}

app.post('/wdltest',function(req,res){
    console.log(req.stack);
    console.log(req.body);
    console.log(req.url);
    console.log(req.query);
    res.json(req.body)
})
//配置服务端口
var server = app.listen(3001, function () {

    var host = server.address().address;

    var port = server.address().port;

    console.log('Example app listening at http://%s:%s', host, port);
})